import React from "react";
import {Modal, Row, Card, Table} from "antd";
import {openNotificationWithIcon} from "utils/comm";
import { connect } from "dva";


class ErrorList extends React.Component {

  columns = [
    {
      title: "序号",
      dataIndex: "id",
      render:(text, record, index) => this.getEllipsisCell(`${index+1}`, 30),
    },
    {
      title: "错误方法",
      dataIndex: "ErrorMethod",
      render: (v) => this.getEllipsisCell(v, 79),
    },
    {
      title: "错误信息",
      dataIndex: "ErrorMessage",
      render: (v) => this.getEllipsisCell(v, 100),
    },
  ];

  constructor(props) {
    super(props);
    this.openNotificationWithIcon = openNotificationWithIcon;
  }


  getEllipsisCell = (v, maxWidth) => {
    return (
      <span
        style={{
          display: "inline-block",
          maxWidth,
        }}
        title={v}
      >
        {v}
      </span>
    );
  }

  handleCancel = () => {
    const {handleErrorCancel} = this.props;
    handleErrorCancel(false);
  };



  render() {
    const { visible, errorMessage } = this.props;

    const {
      title = '错误信息列表',
    } = this.props;

    return (
      <Modal
        title={title}
        visible={visible}
        onCancel={this.handleCancel}
        footer={null}
        width="800px"
      >
        <Row style={{ height: 352 }}>
          <Card
            size="small"
            bodyStyle={{ height: 323, overflow: "auto" }}
          >
            <div>
              <Table
                rowKey="id"
                columns={this.columns}
                dataSource={errorMessage}
              />
            </div>
          </Card>
        </Row>
      </Modal>
    );
  }
}
const ConnectTreeStore = (Component) => connect(({ loading }) => ({
  loading,
}))(Component);

export default ConnectTreeStore(ErrorList);
